//
//  InformationViewController.m
//  DianNaoWang
//
//  Created by dllo on 15/11/2.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "SearchBarViewController.h"
#import "Header.h"
#import "CFNetworkFromAFNetworking.h"
#import "DataModel.h"
#import "ChannelList.h"
#import "ForumArticleModel.h"
#import "CFWebViewController.h"
#import "detaiPageForPoductionTableViewCell.h"
#import "ForumTableViewCell.h"
#import "ForITPageSearchCell.h"
#import "ForITPageSearchModel.h"
#import "MJRefresh.h"
#import "MBProgressHUD.h"
#import "WebViewController.h"
#import "DataBaseManager.h"
@interface SearchBarViewController ()<UITextFieldDelegate,UITableViewDataSource,UITableViewDelegate>
@property(nonatomic, retain)UISearchBar *searchBar;
@property(nonatomic, retain)UITextField *textField;
@property(nonatomic, retain)UIButton *button;
@property(nonatomic, retain)UIImageView *listImView;
@property(nonatomic, assign)NSInteger flag;
@property(nonatomic, retain)NSString *keyWord;
@property(nonatomic, assign)NSInteger page;
@property(nonatomic, retain)NSMutableArray *dataSourceArray;
@property(nonatomic, retain)UITableView *tableView;
@property(nonatomic, retain)NSArray *arrayL;
@property(nonatomic, retain)UITableView *tableViewL;
@property(nonatomic, retain)MBProgressHUD *HUD;
@property(nonatomic, retain)UILabel *Nonelabel;
@property(nonatomic, retain)UITableView *dataTableView;
@property(nonatomic, retain)NSMutableArray *array;
@property(nonatomic, retain)NSString *infoStyle;
//@property(nonatomic, assign)NSInteger textLength;
//@property(nonatomic, retain)NSString *character;
//@property(nonatomic, retain)UINavigationController *nav;
@end

@implementation SearchBarViewController
-(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden = YES;
}
-(void)viewWillDisappear:(BOOL)animated
{
    self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    _page = 1;
    _keyWord = nil;
    
#pragma -mark 做一个与navgationbar等大的背景
    UIView *backgroundView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 64)];
    backgroundView.backgroundColor = NavigationBarBackgroundColor;

#pragma mark - 制作searchbar
    
    //做一个搜索栏左视图
    UIView *leftView = [[UIView alloc]initWithFrame:CGRectMake(5, 5, 40, 20)];
    
    //左视图上放一个button
    _button = [UIButton buttonWithType:UIButtonTypeSystem];
    _button.frame = CGRectMake(0, 0, 40, 20);
    [_button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [_button addTarget:self action:@selector(buttonAction1) forControlEvents:UIControlEventTouchUpInside];
    [leftView addSubview:_button];
    
    //创建一个TextField
    _textField = [[UITextField alloc]initWithFrame:CGRectMake(20 * FitWidth, 30, ScreenWidth - 100 * FitWidth, 25)];
    _textField.delegate = self;
    _textField.borderStyle = UITextBorderStyleRoundedRect;
    _textField.adjustsFontSizeToFitWidth = YES;
    _textField.leftView = leftView;
    _textField.leftViewMode = UITextFieldViewModeAlways;
    _textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    [_textField setKeyboardType:UIKeyboardTypeWebSearch];
    [_textField becomeFirstResponder];
    [_textField addTarget:self action:@selector(valueChangeTextfield:) forControlEvents:UIControlEventEditingChanged];
    
#pragma mark 取消按钮
    UIButton *buttonRight = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonRight.frame = CGRectMake(ScreenWidth - 60, _textField.frame.origin.y - 3, 40, 30);
    buttonRight.titleLabel.font = [UIFont systemFontOfSize:18];
    [buttonRight setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buttonRight setTitle:@"取消" forState:UIControlStateNormal];
    [buttonRight addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [backgroundView addSubview:buttonRight];
    
#pragma mark 创建左视图点击后弹出的 tableViewL的数据源
    self.arrayL = @[@" 资讯", @" 产品", @" 论坛"];
    
#pragma mark 判断从哪一页跳进来的
    switch (_keyID) {
        case 1:{
            _textField.placeholder = @"搜索文章标题";
            [_button setTitle:_arrayL[_keyID - 1] forState:UIControlStateNormal];
        }
            break;
            
        case 2:{
            _textField.placeholder = @"搜索产品";
            [_button setTitle:_arrayL[_keyID - 1] forState:UIControlStateNormal];
        }
            break;
            
        case 3:{
            _textField.placeholder = @"搜索论坛板块或帖子";
            [_button setTitle:_arrayL[_keyID - 1] forState:UIControlStateNormal];
        }
            break;
            
        default:
            break;
    }
    
    [backgroundView addSubview:_textField];
    [self.view addSubview:backgroundView];
    
#pragma mark - 创建 显示搜索得到的数据的tableView
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight - 64) style:UITableViewStylePlain];
    _tableView.tableFooterView = [[UIView alloc]init];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.showsHorizontalScrollIndicator = NO;
    _tableView.showsVerticalScrollIndicator = NO;
    _tableView.backgroundColor = BackgroundColor;
    [self.view addSubview:_tableView];
    
    _listImView = [[UIImageView alloc]initWithFrame:CGRectMake(20, _textField.frame.origin.y + _textField.frame.size.height + 10, 0, 0)];
    _listImView.image = [UIImage imageNamed:@"qipao"];
    _listImView.userInteractionEnabled = YES;
    
    
    _tableViewL = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
    _tableViewL.tableFooterView = [[UIView alloc]init];
    _tableViewL.delegate = self;
    _tableViewL.dataSource = self;
    _tableViewL.backgroundColor = [UIColor blackColor];
    [_listImView addSubview:_tableViewL];
    
#pragma mark MJ刷新
    _tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        _page = 1;
        [self getData];
    }];
    _tableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        _page++;
        [self getData];
    }];
    
    
#pragma mark 提示框
    _Nonelabel = [[UILabel alloc]initWithFrame:CGRectMake(backgroundView.frame.origin.x, backgroundView.frame.origin.y + backgroundView.frame.size.height + 50, backgroundView.frame.size.width, 20)];
    _Nonelabel.font = [UIFont systemFontOfSize:16];
    _Nonelabel.text = nil;
    _Nonelabel.textAlignment = 1;
    [self.view addSubview:_Nonelabel];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(colorChange) name:@"colorChange" object:nil];
    
#pragma mark 实时搜索栏
    _dataTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight - 64) style:UITableViewStylePlain];
    _dataTableView.tableFooterView = [[UIView alloc]init];
    _dataTableView.delegate = self;
    _dataTableView.dataSource = self;
    _tableView.showsHorizontalScrollIndicator = NO;
    _tableView.showsVerticalScrollIndicator = NO;
    _dataTableView.tableFooterView = [[UIView alloc]init];
    _dataTableView.backgroundColor = BackgroundColor;
    [self.view addSubview:_dataTableView];
    [self.view addSubview:_listImView];
    
#pragma mark 菊花
    UIButton *buttonCancel = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonCancel.frame = CGRectMake(ScreenWidth - 60, _textField.frame.origin.y - 3, 40, 30);
    buttonCancel.titleLabel.font = [UIFont systemFontOfSize:18];
    [buttonCancel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [buttonCancel setTitle:@"取消" forState:UIControlStateNormal];
    [buttonCancel addTarget:self action:@selector(buttonCacelAction) forControlEvents:UIControlEventTouchUpInside];
    
    
    _HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    _HUD.backgroundColor = [UIColor clearColor];
    _HUD.labelText = @"正在刷新";
    _HUD.detailsLabelText = @"请耐心等待!";
    _HUD.hidden = YES;
    //[_HUD hide:YES afterDelay:10];
    [_HUD addSubview:buttonCancel];
}
- (void)colorChange
{
    _tableView.backgroundColor = BackgroundColor;
    [_tableView reloadData];
}


#pragma mark - button的点击方法
//
- (void)buttonAction
{
    [_textField resignFirstResponder];
    [self dismissViewControllerAnimated:YES completion:nil];
}

//点击出现tableView
- (void)buttonAction1
{
    if (_flag) {
        [UIView animateWithDuration:.2 animations:^{
            _listImView.frame = CGRectMake(35, _textField.frame.origin.y + _textField.frame.size.height, 0, 0);
            _tableViewL.frame = CGRectMake(10, 10, 0, 0);
        }];
        _flag = 0;
    }else{
        [UIView animateWithDuration:.2 animations:^{
            _listImView.frame = CGRectMake(35, _textField.frame.origin.y + _textField.frame.size.height, 110, 170);
            _tableViewL.frame = CGRectMake(20, 10, 70, 150);
        }];
        _flag = 1;
    }
}


#pragma mark - textFiled值变化时触发事件
- (void)valueChangeTextfield:(UITextField *)textfield
{
    self.array = [NSMutableArray array];
    [_dataTableView reloadData];
    self.keyWord = textfield.text;//一定用self 初始化赋值 要么会过度释放
    [self getArray];
    _dataTableView.frame = CGRectMake(0, 64, ScreenWidth, ScreenHeight - 64);
}

#pragma mark - 键盘回收 并获取搜索数据 **铺数据
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    _dataTableView.frame = CGRectZero;
    [_textField resignFirstResponder];
    
    _HUD.hidden = NO;
    [self getData];
    return YES;
}
-(void)buttonCacelAction
{
    _HUD.hidden = YES;
}


#pragma mark - 获取数据
#warning 加保护***********
-(void)getData
{
    ////NSLog(@"keyWord%@", _keyWord);
    NSString *urlString = [NSString string];
    if (_keyWord) {
        self.keyWord = [_keyWord stringByReplacingOccurrencesOfString:@" " withString:@""];
        ////NSLog(@"getData%@", _keyWord);
    }
    switch (_keyID) {
        case 1:{
            if (_page == 1) {
                self.dataSourceArray = [NSMutableArray array];
                ////NSLog(@"789");
                [_tableView reloadData];
                _Nonelabel.text = @"没有你想要搜索的内容";
            }
            urlString = [NSString stringWithFormat:@"http://lib.wap.zol.com.cn/ipj/searchArticle/?v=1.0&isReviewing=NO&kword=%@&page=%ld&vs=iph430", _keyWord, _page];
            [urlString stringByReplacingOccurrencesOfString:@" " withString:@""];
            [CFNetworkFromAFNetworking askObjectByURLString:urlString BodyString:nil WithObjectBlock:^(id object) {
                if (_page == 1) {
                    self.dataSourceArray = [NSMutableArray array];
                    //NSLog(@"123");
                    [_tableView reloadData];
                }
                for (NSDictionary *dic in object) {
                    ForITPageSearchModel *forITM = [[ForITPageSearchModel alloc]init];
                    [forITM setValuesForKeysWithDictionary:dic];
                    [self.dataSourceArray addObject:forITM];
                }
                [_tableView reloadData];
                [_tableView.header endRefreshing];
                [_tableView.footer endRefreshing];
                _HUD.hidden = YES;
                if (_dataSourceArray.count == 0) {
                    _Nonelabel.text = @"没有你想要搜索的内容";
                }else{_Nonelabel.text = @"";}
            }];
        }
            break;
            
        case 2:{
            if (_page == 1) {
                self.dataSourceArray = [NSMutableArray array];
                ////NSLog(@"789");
                [_tableView reloadData];
                _Nonelabel.text = @"没有你想要搜索的内容";
            }
            urlString = [NSString stringWithFormat:@"http://lib3.wap.zol.com.cn/index.php?c=Advanced_List_V1&keyword=%@&noParam=1&num=20&page=%ld&priceId=noPrice", _keyWord, _page];
            [urlString stringByReplacingOccurrencesOfString:@" " withString:@""];
            [CFNetworkFromAFNetworking askObjectByURLString:urlString BodyString:nil WithObjectBlock:^(id object) {
                if (_page == 1) {
                    self.dataSourceArray = [NSMutableArray array];
                    //NSLog(@"456");
                    [_tableView reloadData];
                }
                NSArray *array = [object objectForKey:@"data"];
                for (NSDictionary *dic in array) {
                    DataModel *PLM = [[DataModel alloc]init];
                    [PLM setValuesForKeysWithDictionary:dic];
                    [self.dataSourceArray addObject:PLM];
                }
                [_tableView reloadData];
                [_tableView.header endRefreshing];
                [_tableView.footer endRefreshing];
                _HUD.hidden = YES;
                if (_dataSourceArray.count == 0) {
                    _Nonelabel.text = @"没有你想要搜索的内容";
                }else{_Nonelabel.text = @"";}
            }];
        }
            break;
            
        case 3:{
            if (_page == 1) {
                self.dataSourceArray = [NSMutableArray array];
                ////NSLog(@"789");
                [_tableView reloadData];
                _Nonelabel.text = @"没有你想要搜索的内容";
            }
            urlString = [NSString stringWithFormat:@"http://lib.wap.zol.com.cn/bbs/ios/search.php?&isReviewing=NO&kword=%@&page=%ld&type=book&vs=iph430", _keyWord, _page];
            [urlString stringByReplacingOccurrencesOfString:@" " withString:@""];
            [CFNetworkFromAFNetworking askObjectByURLString:urlString BodyString:nil WithObjectBlock:^(id object) {
                
                for (NSDictionary *dic in object) {
                    ForumArticleModel *FAM = [[ForumArticleModel alloc]init];
                    [FAM setValuesForKeysWithDictionary:dic];
                    [self.dataSourceArray addObject:FAM];

                }
                [_tableView reloadData];
                [_tableView.header endRefreshing];
                [_tableView.footer endRefreshing];
                _HUD.hidden = YES;
                if (_dataSourceArray.count == 0) {
                    _Nonelabel.text = @"没有你想要搜索的内容";
                }else{_Nonelabel.text = @"";}
            }];
        }
            break;
            
        default:
            break;
    }

}

#pragma mark -获取实时数据
-(void)getArray
{
    if (_keyWord) {
        self.keyWord = [_keyWord stringByReplacingOccurrencesOfString:@" " withString:@""];
        ////NSLog(@"%@", _keyWord);
    }
    NSString *urlString = [NSString stringWithFormat:@"http://lib.wap.zol.com.cn/ipj/autoComplateZolM.php?&isReviewing=NO&key=%@&m=pro&vs=iph430", _keyWord];
    ////NSLog(@"%@", urlString);
    [CFNetworkFromAFNetworking askObjectByURLString:urlString BodyString:nil WithObjectBlock:^(id object) {
        self.array = object;
        if (_array.count != 0) {
            [_dataTableView reloadData];
        }
    }];
}

#pragma mark - tableView设置
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == _tableView) {
        return _dataSourceArray.count;
    }
    if (tableView == _dataTableView) {
        return _array.count;
    }
    return _arrayL.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == _tableView) {
        switch (_keyID) {
            case 1:
            {
                NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:contentTextSize, NSFontAttributeName, nil];
                CGRect rect = [[_dataSourceArray[indexPath.row] title] boundingRectWithSize:CGSizeMake(ScreenWidth - 20 * FitWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
                return rect.size.height + 50 * FitHeight;
            }
                
            case 2:
            {
                return 100;
            }

            case 3:
            {
                _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
                return 100;
            }
        }
    }
    return 50;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == _dataTableView && _array.count > 0) {
        static NSString *identifierD = @"cellD";
        UITableViewCell *Dcell = [tableView dequeueReusableCellWithIdentifier:identifierD];
        if (!Dcell) {
            Dcell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifierD];
        }
        Dcell.backgroundColor = BackgroundColor;
        Dcell.textLabel.textColor = contenttextColor;
        Dcell.textLabel.text = _array[indexPath.row];
        return Dcell;
    }
    if (tableView == _tableView) {
        switch (_keyID) {
            case 1:{
                static NSString *identifier1 = @"cell1";
                ForITPageSearchCell *cell1 = [tableView dequeueReusableCellWithIdentifier:identifier1];
                if (!cell1) {
                    cell1 = [[ForITPageSearchCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier1];
                }
                //防止搜索结果为空加的保护
                if (_dataSourceArray[indexPath.row]) {
                    cell1.FITPModel = _dataSourceArray[indexPath.row];
                }
                if (_keyWord) {
                    cell1.keyWork = [_keyWord copy];
                }
                return cell1;
            }
                break;
                
            case 2:{
                static NSString *identifier2 = @"cell2";
                detaiPageForPoductionTableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:identifier2];
                if (!cell2) {
                    cell2 = [[detaiPageForPoductionTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier2];
                }
                if (_dataSourceArray[indexPath.row]) {
                    cell2.dataModel = _dataSourceArray[indexPath.row];
                }
                //要放在给datamodel赋值之后 否则datamodel的name为空
                if (_keyWord) {
                    cell2.keyWord = _keyWord;
                }
                return cell2;
            }
                break;
                
            case 3:{
                static NSString *identifier3 = @"cell3";
                ForumTableViewCell *cell3 = [tableView dequeueReusableCellWithIdentifier:identifier3];
                if (!cell3) {
                    cell3 = [[ForumTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier3];
                }
                if (_dataSourceArray[indexPath.row]) {
                    cell3.ForumAModel = _dataSourceArray[indexPath.row];
                }
                if (_keyWord) {
                    cell3.keyWord = _keyWord;
                }
                return cell3;
            }
                break;
                
            default:
                break;
        }
    }
    static NSString *identifier4 = @"cell4";
    UITableViewCell *cell4 = [tableView dequeueReusableCellWithIdentifier:identifier4];
    if (!cell4) {
        cell4 = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier4];
    }
    cell4.backgroundColor = [UIColor blackColor];
    cell4.textLabel.textColor = [UIColor whiteColor];
    cell4.textLabel.text = _arrayL[indexPath.row];
    return cell4;
}

//点击小的 tableView 刷新大的tableView
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == _dataTableView && _array.count > 0) {
        _HUD.hidden = NO;
        _dataTableView.frame = CGRectZero;
        [_textField resignFirstResponder];
        if (_array[indexPath.row]) {
            self.keyWord = _array[indexPath.row];
            ////NSLog(@"%@", _keyWord);
            _textField.text = _keyWord;
            [self getData];
        }
    }
    if (tableView == _tableViewL) {
        _HUD.hidden = NO;
        _keyID = indexPath.row + 1;
        _page = 1;
        [self getData];
        [UIView animateWithDuration:.2 animations:^{
            _listImView.frame = CGRectMake(35, _textField.frame.origin.y + _textField.frame.size.height, 0, 0);
            _tableViewL.frame = CGRectMake(10, 10, 0, 0);
        }];
        [_button setTitle:_arrayL[indexPath.row] forState:UIControlStateNormal];
        _flag = 0;
    }
    if (tableView == _tableView) {
        switch (_keyID) {
            case 1:
            {
                ForITPageSearchModel *Fitp = _dataSourceArray[indexPath.row];
                
                CFWebViewController *cfwebVC = [[CFWebViewController alloc]init];
                NSString *urlString = [NSString stringWithFormat:@"http://lib.wap.zol.com.cn/ipj/clientArticle/?v=3.1&fontSize=middle&id=%@&picHeight=2000&picOpen=1&picWidth=500&tag=0&vs=iph430", Fitp.document_id];
                FavoriteWapPage *FWP = [[FavoriteWapPage alloc]init];
                FWP.wapUrlString = urlString;
                FWP.title = Fitp.title;
                cfwebVC.favorWap = FWP;
                [self.navigationController pushViewController:cfwebVC animated:YES];
            }
                break;
            case 2:
            {
                WebViewController *webView = [[WebViewController alloc]init];
                webView.Id = [_dataSourceArray[indexPath.row] Id];
                FavoriteWapPage *fwp = [[FavoriteWapPage alloc]init];
                fwp.title = [_dataSourceArray[indexPath.row] name];
                NSString *urlString = [NSString stringWithFormat:@"http://wap.zol.com.cn/369/%@/index.html", [_dataSourceArray[indexPath.row] Id]];
                fwp.wapUrlString = [_dataSourceArray[indexPath.row] Id];
                [DataBaseManager creatPriceTable];
                NSArray *arr = [DataBaseManager selectPrice];
                if (arr.count > 10) {
                    [DataBaseManager deleteFavoritePricePage:arr[0]];
                }
                NSMutableArray * arrTitle = [NSMutableArray array];
                for (FavoriteWapPage *fwP in arr) {
                    [arrTitle addObject:fwP.title];
                }
                if (![arrTitle containsObject:fwp.title]) {
                    [DataBaseManager insertFavoritePricePage:fwp];
                }
                
                [self.navigationController pushViewController:webView animated:YES];
            }
                break;
            case 3:
            {//NSLog(@"3");
                ForumArticleModel *hotArticleModel = _dataSourceArray[indexPath.row];
                CFWebViewController *CFWVC = [[CFWebViewController alloc]init];
                NSString *urlstring = [NSString stringWithFormat:@"http://lib.wap.zol.com.cn/bbs/ios/detail.php?bbs=%@&bbsid=%ld&boardid=%@&bookid=%@&type=0&page=1&picOpen=1&fontSize=middle&fromType=&vs=430&ssid=(null)", hotArticleModel.bbsname, hotArticleModel.bbsid, hotArticleModel.boardid, hotArticleModel.bookid];
                FavoriteWapPage *faWapPage = [[FavoriteWapPage alloc]init];
                faWapPage.wapUrlString = urlstring;
                faWapPage.title = hotArticleModel.title;
                CFWVC.favorWap = faWapPage;
                [self.navigationController pushViewController:CFWVC animated:YES];
            }
                break;
            default:
                break;
        }
    }
    if (_flag == 1) {
        _listImView.frame = CGRectMake(35, _textField.frame.origin.y + _textField.frame.size.height, 0, 0);
        _tableViewL.frame = CGRectMake(10, 10, 0, 0);
        _flag = 0;
    }
    
}

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    [_textField resignFirstResponder];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
